package com.house.java.util;

import com.house.java.model.SecondHouse;

public class SecondHouseUtils {
	
	public void setSecondHouse(SecondHouse house,String fieldName,String fieldValue){
		if(StringUtils.hasLength(fieldValue) && StringUtils.hasLength(fieldName)){
			setFieldForSecondHouse(house, fieldName, fieldValue);
		}
	}
	
	/**
	 * 根据属性名设置SecondHouse的属性值
	 * @param house
	 */
	public void setFieldForSecondHouse(SecondHouse house,String fieldName,String fieldValue){
		if("totalPrice".equals(fieldName)){
			house.setTotalPrice(Long.parseLong(fieldValue));
		}else if("id".equals(fieldName)){
			house.setId(Long.valueOf(fieldValue));
		}else if("houseType".equals(fieldName)){
			house.setHouseType(Integer.parseInt(fieldValue));
		}else if("houseArea".equals(fieldName)){
			house.setHouseArea(Integer.parseInt(fieldValue));
		}else if("telNumber".equals(fieldName)){
			house.setTelNumber(fieldValue);
		}else if("houseTime".equals(fieldName)){
			house.setHouseTime(fieldValue);
		}else if("houseChaoxiang".equals(fieldName)){
			house.setHouseChaoxiang(fieldValue);
		}else if("floor".equals(fieldName)){
			house.setFloor(Integer.parseInt(fieldValue));
		}else if("totalFloor".equals(fieldName)){
			house.setTotalFloor(Integer.parseInt(fieldValue));
		}else if("locationCountryCode".equals(fieldName)){
			house.setLocationCountryCode(Integer.parseInt(fieldValue));
		}else if("locationProvinceCode".equals(fieldName)){
			house.setLocationProvinceCode(Integer.parseInt(fieldValue));
		}else if("locationCityCode".equals(fieldName)){
			house.setLocationCityCode(Integer.parseInt(fieldValue));
		}else if("locationDistrict".equals(fieldName)){
			house.setLocationDistrict(Integer.parseInt(fieldValue));
		}else if("zhuangxiuCategory".equals(fieldName)){
			house.setZhuangxiuCategory(Integer.parseInt(fieldValue));
		}else if("houseCategory".equals(fieldName)){
			house.setHouseCategory(Integer.parseInt(fieldValue));
		}else if("buildCategory".equals(fieldName)){
			house.setBuildCategory(Integer.parseInt(fieldValue));
		}else if("chanquanQuality".equals(fieldName)){
			house.setChanquanQuality(Integer.parseInt(fieldValue));
		}else if("seeTime".equals(fieldName)){
			house.setSeeTime(Integer.parseInt(fieldValue));
		}else if("loupanName".equals(fieldName)){
			house.setLoupanName(fieldValue);
		}else if("location".equals(fieldName)){
			house.setLocation(fieldValue);
		}else if("housePeitao".equals(fieldName)){
			house.setHousePeitao(fieldValue);
		}else if("images".equals(fieldName)){
			fieldValue = StringUtils.hasLength(house.getImages())?(house.getImages()+StringUtils.semicolon+fieldValue):fieldValue;
			house.setImages(fieldValue);
		}
	}

}
